<template>
  <div class="hearder">
    <!-- 左侧 -->
    <div class="left" v-if="f1 ? true : false" @click="goBack">
      <van-icon name="arrow-left" />
      <span>返回</span>
    </div>
    <!-- 标题 -->
    <h5>黑马程序员.vant</h5>
    <!-- 右边 -->
    <div class="right" v-if="f2 ? true : false" @click="add">添加</div>
  </div>
</template>

<script>
export default {
  props: ['f1', 'f2'],
  data() {
    return {}
  },
  created() {},
  methods: {
    //   点击返回按钮
    goBack() {
      this.$router.go(-1)
    },
    // 点击添加按钮,跳转到添加商品页面
    add() {
      this.$router.push('/addgoods')
    }
  }
}
</script>

<style lang="less" scoped>
.hearder {
  position: fixed;
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 13px;
  background-color: #1989fa;
  color: #fff;
  z-index: 1;
  top: 0;
  left: 0;
  .left {
    position: absolute;
    left: 10px;
    top: 0;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .right {
    position: absolute;
    right: 20px;
    top: 0;
  }
  h5 {
    text-align: center;
    line-height: 40px;
    margin: 0;
    font-size: 14px;
    font-weight: normal;
  }
}
</style>
